<?php


namespace app\controller;


class Car extends BackendController{

    protected $noNeedRight=['*'];
    protected $model = null;
    public function _initialize()
    {
        parent::_initialize();
        $this->model = new \app\model\MqttCarPushInfo();
    }


    public function after_index($lists){
        $devices=[];
        foreach ($lists as &$list){
            if(!isset($devices[$list['device_id']])){
                $device=\app\model\ViidDevice::where('device_id',$list['device_id'])->find();
                if($device){
                    $aizone=\app\model\Aizone::where('id',$device['aizone_id'])->find();
                    $device['aizone_name']=$aizone['name'];
                    if($aizone){
                        $devices[$list['device_id']]=$device;
                    }
                }
            }
            $list['device']=$devices[$list['device_id']];
        }
        return $lists;
    }


}